
/**
 * This class represents an edge.
 * Each edge links node1 with node2 with confidence 
 * as the chance if interaction between them. 
 * @author liat
 * Last updater: Oded
 * Date: 10.8.09 15:00
 */

public class Edge {
	
	private double _confidence;
	private StringOrderedPair _prots;
	
	
	public Edge(String prot1, String prot2,double confidence) {
		this(new StringOrderedPair(prot1, prot2), confidence);
	}
	
	public Edge(StringOrderedPair sop, double confidence) {
		_confidence = confidence;
		_prots = new StringOrderedPair(sop);		
	}
	
	public String getProt1() {
		return _prots.getString1();
	}

	public String getProt2() {
		return _prots.getString2();
	}
	
	public String getProts() {
		return _prots.getString1();
	}
	
	public double getConfidence() {
		return _confidence;
	}
	
	public void setConfidence(double confidence) {
		if ((confidence >= 0) && (confidence <= 1))
			_confidence = confidence;
	}
	
	/**
	 * Overwrites the equals of the Java object class.
	 * Uses the two prots as a 'primary key'. 
	 */
	public boolean equals(Object obj) {
		if (obj instanceof Edge) {
			return _prots.equals(((Edge)obj)._prots);
		}
		return false;
	}
	
	public int hashCode() {
		return _prots.hashCode();
	}
	
}
